package cn.wolfcode.luowowo.ticket.service.impl;

import cn.wolfcode.luowowo.ticket.domain.Ticket;
import cn.wolfcode.luowowo.ticket.domain.TicketDetail;
import cn.wolfcode.luowowo.ticket.mapper.TicketDetailMapper;
import cn.wolfcode.luowowo.ticket.mapper.TicketMapper;
import cn.wolfcode.luowowo.ticket.service.ITicketDetailService;
import cn.wolfcode.luowowo.ticket.service.ITicketService;
import com.alibaba.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@Service
public class TicketDetailServiceImpl implements ITicketDetailService{

    @Autowired
    private TicketDetailMapper ticketDetailMapper;

    @Override
    public void saveOrUpdate(TicketDetail ticketDetail) {
        if(ticketDetail.getId() != null){
            ticketDetailMapper.updateByPrimaryKey(ticketDetail);
        }else{
            ticketDetailMapper.insert(ticketDetail);
        }
    }

    @Override
    public TicketDetail get(Long id) {
        return ticketDetailMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<TicketDetail> list() {
        return ticketDetailMapper.selectAll();
    }
}
